/**基础类 */
import wepy from 'wepy'
import pages from '../config/pages'
import urls from '../config/urls'
import utils from '../models/utils'
import openId from '../models/accounts/openId'

export default class PageBase extends wepy.page {
    constructor() {
        super()
        // 获取用户的openId
        openId($openId => this.$openId = $openId)
    }

    /**页面路径 */
    $pages = pages
    /**后端接口 */
    $urls = urls
    /**post请求 */
    $post = utils.$post
    /**当前用户标识 在子页面的data中也要添加$openId=null才能使用watch监听$openId*/
    $openId = null

    getSelectorRect(el) {
        var query = wx.createSelectorQuery();
        query.select(el).boundingClientRect();
        query.selectViewport().scrollOffset();

        return new Promise((resolve) => {
            query.exec(res => resolve(res))
        });
    }
}